package com.lzm.ydpt.module.mall.activity;

import android.view.View;

import com.byt.framlib.base.BaseActivity;
import com.byt.framlib.baseadapter.rv.RvCommonAdapter;
import com.byt.framlib.baseadapter.rv.RvViewHolder;
import com.byt.framlib.commonwidget.LoadingTip;
import com.byt.framlib.commonwidget.NormalTitleBar;
import com.byt.framlib.commonwidget.OnNoDoubleClickListener;
import com.byt.framlib.commonwidget.refresh.RefreshHeaderView;
import com.lzm.ydpt.R;
import com.lzm.ydpt.entity.mall.OrderMsgBean;
import com.lzm.ydpt.mvp.contract.OrderMsgContract;
import com.lzm.ydpt.mvp.presenterimpl.OrderMsgPresenterImpl;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

/**
 * 订单消息
 */
public class OrderMsgActivity extends BaseActivity<OrderMsgPresenterImpl> implements OrderMsgContract.View {
    @BindView(R.id.ntb_order_msg)
    NormalTitleBar ntb_order_msg;
    @BindView(R.id.ltp_order_msg)
    LoadingTip ltp_order_msg;
    @BindView(R.id.srf_order_msg)
    SmartRefreshLayout srf_order_msg;
    @BindView(R.id.rv_order_msg)
    RecyclerView rv_order_msg;
    private RvCommonAdapter<OrderMsgBean> adpter = null;
    private List<OrderMsgBean> mOrderMsgBeanList = new ArrayList<>();
    @Override
    public int getLayoutId() {
        return R.layout.activity_order_msg;
    }

    @Override
    public OrderMsgPresenterImpl initPreData() {
        return new OrderMsgPresenterImpl(this);
    }

    @Override
    public void initView() {
        ntb_order_msg.setTitleText("订单消息");
        ntb_order_msg.setOnBackListener(new OnNoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
              finish();
            }
        });
        setRefreshData();
        initAdapter();
    }

    private void setRefreshData() {
        setRefreshLayout(srf_order_msg);
        srf_order_msg.setEnableLoadMore(false);
        srf_order_msg.setEnableRefresh(true);
        srf_order_msg.setRefreshHeader(new RefreshHeaderView(mBContext).getHeaderStyleStaffF4());
        srf_order_msg.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

            }

            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }
        });
    }

    private void initAdapter() {
        mOrderMsgBeanList.add(new OrderMsgBean());
        mOrderMsgBeanList.add(new OrderMsgBean());
        mOrderMsgBeanList.add(new OrderMsgBean());
        mOrderMsgBeanList.add(new OrderMsgBean());
        mOrderMsgBeanList.add(new OrderMsgBean());
        rv_order_msg.setLayoutManager(new LinearLayoutManager(mBContext));
        adpter = new RvCommonAdapter<OrderMsgBean>(mBContext,mOrderMsgBeanList,R.layout.item_order_msg_rv) {
            @Override
            protected void convert(RvViewHolder holder, OrderMsgBean orderMsgBean, int position) {
//                holder.setText(R.id.tv_order_msg_state,"");
//                holder.setText(R.id.tv_order_msg_time,"");
//                holder.setText(R.id.tv_order_msg_titile,"");
//                holder.setText(R.id.tv_order_msg_num,"");
//                holder.setText(R.id.tv_order_msg_logistic,"");
//                ImageLoaderUtils.display(holder.getView(R.id.img_order_msg_ablum),"");
//                holder.getConvertView().setOnClickListener(new OnNoDoubleClickListener() {
//                    @Override
//                    protected void onNoDoubleClick(View v) {
//                        showShortToast("订单详情");
//                    }
//                });
            }
        };
        rv_order_msg.setAdapter(adpter);
    }

    @Override
    public void onOrderMsg() {

    }

    @Override
    public void showMessage(String message, String method) {

    }

    @Override
    public void showErrorView(String msg) {

    }
}
